
export default function collector(){
    let contexts = require.context("./code/", true, /^\.\/.*\/selfRouter\.js$/);  
    let elements = {};
    function addElements(egs){
        if(egs){
            for(var eg in egs){
                if(!elements[eg]){
                    elements[eg] = {};
                }
                for(var ek in egs[eg]){
                    elements[eg][ek] = egs[eg][ek];
                }
            }
        }
    }
    contexts.keys().forEach((key) => { 
        let name = /\.\/([^/]+)\//g.exec(key);   
        let elements = contexts(key).default;  
        addElements(elements);  
    });  

    this.getElement = function(type,name){
        if(type!=null&&name!=null){
            if(elements[type]){
                return elements[type][name];
            }else{
                return null;
            }
        }
        return null;
    }

    this.getElements = function(type){
        if(type!=null){
            return elements[type];
        }
        return null;
    }

}

